import React from 'react';
import DataTable from '../../UI/DataTable';
import PageContainer from '../../UI/PageContainer';
import './SoftwarePage.css';

const SoftwarePage = () => {
  const data = [
    {
      id: 1,
      name: '智能数据分析系统',
      id: 'SW001',
      keywords: '数据分析, 人工智能, 软件',
      copyrightOwner: '张三, 李四',
      authorRank: '第一作者',
      finishDevDate: '2023-01-01',
      finishPubDate: '2023-01-15',
      power: '原始取得',
      powerRange: '全部权利',
      certificateNumber: '2023SR001234',
      files_certificate: [
        { name: '软著证书.pdf', size: 2048576, type: 'application/pdf' }
      ],
      files_sourceCode: [
        { name: '源码包.zip', size: 10240000, type: 'application/zip' },
        { name: '用户手册.pdf', size: 3072000, type: 'application/pdf' }
      ]
    },
    {
      id: 2,
      name: '机器学习算法库',
      id: 'SW002',
      keywords: '机器学习, 算法库, 开源',
      copyrightOwner: '王五, 赵六',
      authorRank: '第二作者',
      finishDevDate: '2023-03-01',
      finishPubDate: '2023-03-15',
      power: '原始取得',
      powerRange: '全部权利',
      certificateNumber: '2023SR005678',
      files_certificate: [
        { name: '软著登记证书.pdf', size: 1536000, type: 'application/pdf' }
      ],
      files_sourceCode: [
        { name: '算法库源码.rar', size: 8192000, type: 'application/x-rar-compressed' },
        { name: 'API文档.docx', size: 2048000, type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' }
      ]
    }
  ];

  const stats = [
    { value: 2, label: '软件著作权' },
    { value: 2, label: '已登记' },
    { value: 0, label: '申请中' }
  ];

  const columns = [
    {
      key: 'name',
      title: '软件名称',
      width: '250px',
      render: (value) => (
        <div className="software-page__name">{value}</div>
      )
    },
    { key: 'id', title: 'ID', width: '120px' },
    { 
      key: 'keywords', 
      title: '关键词', 
      width: '200px',
      render: (value) => (
        <div className="software-page__keywords">{value}</div>
      )
    },
    { key: 'copyrightOwner', title: '著作权人', width: '150px' },
    { key: 'authorRank', title: '作者位次', width: '100px' },
    { key: 'finishDevDate', title: '开发完成时间', width: '120px' },
    { key: 'finishPubDate', title: '首次发表时间', width: '120px' },
    { key: 'power', title: '权力取得方法', width: '120px' },
    { key: 'powerRange', title: '权力范围', width: '120px' },
    { key: 'certificateNumber', title: '证书号', width: '150px' },
    {
      key: 'actions',
      title: '操作',
      width: '120px',
      render: () => (
        <div>
          <a className="data-table__action-link data-table__action-link--edit">编辑</a>
          <a className="data-table__action-link data-table__action-link--delete">删除</a>
        </div>
      )
    }
  ];

  return (
    <PageContainer className="software-page">
      <DataTable
        data={data}
        columns={columns}
        showSearch={true}
        title="软件著作权"
        titleIcon="software"
        editType="software"
        searchPlaceholder="搜索软件名称、作者..."
        filterOptions={['已登记', '申请中', '已驳回']}
        onNew={() => console.log('新建软件著作权')}
        onFilter={() => console.log('筛选软件著作权')}
        showPagination={true}
        pageSize={20}
        className="software-page__table"
      />
    </PageContainer>
  );
};

export default SoftwarePage;
